<style>
    .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <div class="layui-form layuimini-form">

            <div class="layui-form-item">
                <label class="layui-form-label required" >所属会员组</label>
                <div class="layui-input-block">
                    <select name="group_id" lay-filter="aihao">
                        <option value=""></option>
                        {{range .place}}
                        <option value="{{.Id}}" {{if eq $.member.Group.Id .Id}}selected {{end}}>{{.MgroupName}}</option>
                        {{end}}
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" value="{{.member.UserName}}" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">登入密码</label>
                <div class="layui-input-block">
                    <input type="text" name="pwd" value="{{.member.Pwd}}" lay-verify="required" lay-reqtext="登入密码不能为空" placeholder="请输入登入密码"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input type="text" name="nickname"  value="{{.member.NickName}}" placeholder="请输入昵称"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">积分</label>
                <div class="layui-input-block">
                    <input type="number" name="score" value="{{.member.Score}}"  placeholder="请输入积分"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">金币</label>
                <div class="layui-input-block">
                    <input type="number" name="coin" value="{{.member.Coin}}" placeholder="请输入金币"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="sex" value="1" title="男" checked="">
                    <input type="radio" name="sex" value="2" title="女">
                    <input type="radio" name="sex" value="3" title="保密">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">手机</label>
                <div class="layui-input-block">
                    <input type="text" name="tel" value="{{.member.Tel}}" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">个人网站</label>
                <div class="layui-input-block">
                    <input type="text" name="user_url" value="{{.member.UserUrl}}"  placeholder="请输入个人网站"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">签名</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入签名" name="signature" class="layui-textarea">{{.member.Signature}}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" value="{{.member.Email}}"  placeholder="请输入邮箱"   class="layui-input">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">会员头像</label>
                <div class="layui-input-block">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test1">上传图片</button>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" id="demo1" style="width: 92px;height:92px" src="{{.member.Headpic}}">
                            <p id="demoText"></p>
                            <input type="hidden" name="pic" id="picd">
                            <input type="hidden" name="oldpic" value="{{.member.Headpic}}">
                        </div>
                    </div>
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否审核</label>
                <div class="layui-input-block">
                    <input type="checkbox" {{if eq .member.Open 1}}checked {{end}} name="open"  lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                </div>
            </div>

            <div class="layui-form-item">
                <input type="hidden" name="Id" value="{{.member.Id}}">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setting">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','jquery','upload'], function () {
        var form = layui.form
            , layer = layui.layer
            ,upload = layui.upload
            ,$ = layui.jquery;

        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: 'https://httpbin.org/post' //改成您自己的上传接口
            ,exts: 'jpg|png|jpeg' //只允许上传压缩文件
            ,accept: 'file' //普通文件
            ,size: 60 //限制文件大小，单位 KB
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                    $("#picd").val(result)
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code > 0){
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });


        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //监听提交
        form.on('submit(setting)', function (data) {
            //获取
            ajaxs("/sys/UpdateMember",data.field,function(res){
                layer.msg(res["Msg"], function () {
                    layer.closeAll()
                });
            },function(res){
                layer.msg(res["Msg"]);
            })
        });

    });
</script>